package com.coreJava.meiju.danli;

import java.util.concurrent.Callable;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

/**
 * 作者: LCG
 * 日期: 2020/2/13 00:40
 * 描述:
 */
public class Test00000 {
    public static void main(String[] args) throws InterruptedException, ExecutionException {

        /*TestDanLi danLi = TestMeiJuDanLi.TESTDANLI.getDanLi();

        TestDanLi danLi2 = TestMeiJuDanLi.TESTDANLI.getDanLi();

        System.out.println(danLi==danLi2);*/

        CountDownLatch countDownLatch=new CountDownLatch(4);

        FutureTask<TestDanLi> f1=new FutureTask<TestDanLi>(new MyCallAble(countDownLatch));

        Thread thread1=new Thread(f1);
        thread1.start();

        FutureTask<TestDanLi> f2=new FutureTask<TestDanLi>(new MyCallAble(countDownLatch));

        Thread thread2=new Thread(f2);
        thread2.start();

        FutureTask<TestDanLi> f3=new FutureTask<TestDanLi>(new MyCallAble(countDownLatch));

        Thread thread3=new Thread(f3);
        thread3.start();

        FutureTask<TestDanLi> f4=new FutureTask<TestDanLi>(new MyCallAble(countDownLatch));

        Thread thread4=new Thread(f4);
        thread4.start();

        countDownLatch.await();


        TestDanLi testDanLi1 = f1.get();
        TestDanLi testDanLi2 = f2.get();
        TestDanLi testDanLi3 = f3.get();
        TestDanLi testDanLi4 = f4.get();

        System.out.println(testDanLi1==testDanLi4);
        System.out.println(testDanLi1==testDanLi2);
        System.out.println(testDanLi1==testDanLi3);


    }
}
